#include "../StdInc.h"
#include "InnerImpl.h"

namespace GSTrader
{
	namespace TradeStrategy
	{
		CInnerFunc::CInnerFunc(CFramework* pFramework) : m_pFramework(pFramework)
		{
			m_nSymbol = -1;
			m_pInnerImpl = new CInnerImpl(pFramework);
		}

		CInnerFunc::~CInnerFunc()
		{
			_delete(m_pInnerImpl)
		}

		void CInnerFunc::BeginCollect(int nType)
		{
			m_nSymbol = nType;
		}

		void CInnerFunc::EndCollect(vector<string>& vString)
		{
			m_nSymbol = -1;

			vString.reserve(m_mapSymbol.size());

			for (auto it : m_mapSymbol)
			{
				vString.push_back(it.first);
			}

			m_mapSymbol.clear();
		}

		bool CInnerFunc::SendOrder(string strAccount, string strInsID, int nType,
		                           string strExchangeID, double dPrice, int nPriceLevel, int nSide, int nOpenClose)
		{
			return false;
		}

		bool CInnerFunc::LimitOrder(string strAccount, string strInsID,
		                            string strExchangeID, double dPrice, int nPriceLevel, int nSide, int nOpenClose)
		{
			return false;
		}

		void CInnerFunc::CancelOrder(COrder* pOrder)
		{

		}

		void CInnerFunc::CancelAllOrder()
		{

		}

		int CInnerFunc::GetExpireDateById(int nInstrumentId)
		{
			if (nInstrumentId < 0)
				return -1;

			CInstrument* pInstrument = m_pFramework->m_pInstrumentManager->GetInstrumentById(nInstrumentId);
			return m_pInnerImpl->GetExpireDate(pInstrument);
		}

		int CInnerFunc::GetExpireDateBySymbol(int nProviderId, string strInstrumentSymbol )
		{
			if (strInstrumentSymbol.empty())
				return  -1;

			if (m_nSymbol == 0 || m_nSymbol == 1)
			{
				m_mapSymbol[strInstrumentSymbol] = nProviderId;
			}

			CInstrument* pInstrument = m_pFramework->m_pInstrumentManager->GetInstrumentBySymbol(strInstrumentSymbol, "");
			return m_pInnerImpl->GetExpireDate(pInstrument);
		}

		double CInnerFunc::GetQuoteById(int nInstrumentId, int nIndex)
		{

			return 0;
		}

		double CInnerFunc::GetQuoteBySymbol(int nProviderId, string strInstrumentSymbol, int nIndex)
		{

			return 0;
		}
	}
}
